Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

block-builder: Add cortex_blockbuilder_blocks_produced_total metric #10538

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

codesome
Copy link
Member

What this PR does

Adds a metric to determine how many blocks were produced for previous, current, and next block period w.r.t. the cycle end time.

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

@codesome codesome requested a review from a team as a code owner January 29, 2025 21:09
Comment on lines -77 to -80
if cfg.NoPartiallyConsumedRegion {
// We should not have a large buffer if we are putting all the records into a block.
cfg.ConsumeIntervalBuffer = 5 * time.Minute
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By removing this override, we can now try different buffer times when we have set NoPartiallyConsumedRegion to true

Signed-off-by: Ganesh Vernekar <[email protected]>
@@ -643,6 +645,22 @@ consumerLoop:
return newState, nil
}

func getBlockCategoryCount(sectionEndTime time.Time, blockMetas []tsdb.BlockMeta) (prev, curr, next int) {
// Doing -30m will take care
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) What does this comment say?

Comment on lines +615 to +618
prev, curr, next := getBlockCategoryCount(sectionEndTime, blockMetas)
b.blockBuilderMetrics.blockCounts.WithLabelValues("previous").Add(float64(prev))
b.blockBuilderMetrics.blockCounts.WithLabelValues("current").Add(float64(curr))
b.blockBuilderMetrics.blockCounts.WithLabelValues("next").Add(float64(next))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered putting these metrics inside TSDBBuilder.CompactAndUpload (ie. make them a part of tsdbMetrics collection). It feels this would require fewer changes in the overall code, and make "magic knowledge", like 2h block ranges, scoped closer together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants